<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content=" " name="Keywords">
<meta content=" " name="Description">
<meta content="eric.wu" name="author">
<meta content="0" http-equiv="expires">
<meta content="no-cache" http-equiv="pragma">
<meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
<meta content="telephone=no, address=no" name="format-detection">
<meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
<title>评论</title>
<!--[if lte IE 9]><script src="http://stc.weimob.com/src/watermark.js"></script><![endif]-->
<!--[if IE 7]><link href="http://stc.weimob.com/css/font_awesome_ie7.css" rel="stylesheet" /><![endif]-->
<link rel="shortcut icon" href="http://stc.weimob.com/img/favicon.ico">
<link rel="stylesheet" type="text/css" href="/sources/css/main.css">
<link rel="stylesheet" type="text/css" href="/sources/css/dialog.css">
<script type="text/javascript" src="/sources/js/wtj.html" async="" type="text/javascript"></script>
<script type="text/javascript" src="/sources/js/jquery_min.js"></script>
<script type="text/javascript" src="/sources/js/swipe.js"></script>
<script type="text/javascript" src="/sources/js/main.js"></script>
<script type="text/javascript" src="/sources/js/dialog_min.js"></script>
<script type="text/javascript" src="/sources/js/helper_min.js"></script>
<script type="text/javascript" src="/sources/js/input.js"></script>
<script>
    var form_emotion = (function(){
        var fe = function(){
            this.values = ["/::)", "/::~", "/::B", "/::|", "/:8-)", "/::<", "/::$", "/::X", "/::Z", "/::'(", "/::-|", "/::@", "/::P", \
            		"/::D", "/::O", "/::(", "/::+", "/:–b", "/::Q", "/::T", "/:,@P", "/:,@-D", "/::d", "/:,@o", "/::g", "/:|-)", "/::!", \
            		"/::L", "/::>", "/::,@", "/:,@f", "/::-S", "/:?", "/:,@x", "/:,@@", "/::8", "/:,@!", "/:!!!", "/:xx", "/:bye", "/:wipe", \
            		"/:dig", "/:handclap", "/:&-(", "/:B-)", "/:<@", "/:@>", "/::-O", "/:>-|", "/:P-(", "/::'|", "/:X-)", "/::*", \
            		"/:@x", "/:8*", "/:pd", "/:<W>", "/:beer", "/:basketb", "/:oo", "/:coffee", "/:eat", "/:pig", "/:rose", "/:fade", \
            		"/:showlove", "/:heart", "/:break", "/:cake", "/:li", "/:bome", "/:kn", "/:footb", "/:ladybug", "/:shit", "/:moon", \
            		"/:sun", "/:gift", "/:hug", "/:strong", "/:weak", "/:share", "/:v", "/:@)", "/:jj", "/:@@", "/:bad", "/:lvu", "/:no", \
            		"/:ok", "/:love", "/:<L>", "/:jump", "/:shake", "/:<O>", "/:circle", "/:kotow", "/:turn", "/:skip", "[挥手]", "/:#-0", \
            		"[街舞]", "/:kiss", "/:<&", "/:&>"].slice(0, -7);
            //console.log(this.values);
            this.spearate= 20
        }

        fe.prototype = {
            rend: function(){
                var that = this;
                var TPL = '{seprateDiv}<dd><span data-key="{k}_{page}_{v}" style="background-position:{xPos}px 0;"></span></dd>{delHTML}';
                var res = iTemplate.makeList(TPL, that.values, function(k,v){
                    return {
                        k: k,
                        v: v,
                        page: Math.floor(k/that.spearate),
                        xPos: -24*k,
                        seprateDiv: (0 == k%that.spearate && 0!=k && k!=that.values.length)?"</div><div>":"",
                        delHTML: (19==k%that.spearate||k==(that.values.length-1) )?'<dd><span data-key="-1_-1_/:del" class="del"></span></dd>':''
                    }
                });
                //console.log(res);
                $("#list_emotion").html('<div>'+res+'</div>');
                var nav_span = new Array(Math.ceil(that.values.length/that.spearate));
                $("#nav_emotion").html('<span class="on">'+nav_span.join("</span><span>")+'</span>');
                that.bind();

                 window.swiper = new Swipe(document.getElementById('page_emotion'), {
                    speed:500,
                    // auto:3000,
                    callback: function(){
                        //$("#nav_list_uls li").removeClass("on").eq(this.index).addClass("on");
                        $("#nav_emotion span").removeClass("on").eq(this.index).addClass("on");
                    }
                });
                return that;
            },
            bind: function(){
                $("#list_emotion").on("click", function(evt){                       
                    if("SPAN" == evt.target.tagName){
                        var val = evt.target.getAttribute("data-key").split('_');
                        myInput.listen(this, {
                            keyCode: -10,
                            srcElement: document.getElementById("form_article"),
                            value:val[2],
                            imgUrl: '{$site_info.route_base}sources/pic/emotion/'+ val[0]+".gif"
                        });
                        this.focus();
                    }
                });
            }

        }

        return new fe();
    })();



    
    $().ready(function(){
        form_emotion.rend();
        myInput.maxLength = 140;
    });


    function submit(){
        var form = document.getElementById("form_1");
        var article = document.getElementById("form_article").innerHTML;
        document.getElementById("form_article_hidden").value = article;
        if(article.length == 0){
            alert("请输入评论内容", 2000);return;
        }
        console.log(form.form_article.value);
        console.log(form);
        //return;
        form.submit();
    }


    function getCaretCharacterOffsetWithin(element) {
        var caretOffset = 0;
        if (typeof window.getSelection != "undefined") {
            var range = window.getSelection().getRangeAt(0);
            var preCaretRange = range.cloneRange();
            preCaretRange.selectNodeContents(element);
            preCaretRange.setEnd(range.endContainer, range.endOffset);
            caretOffset = preCaretRange.toString().length;
        } else if (typeof document.selection != "undefined" && document.selection.type != "Control") {
            var textRange = document.selection.createRange();
            var preCaretTextRange = document.body.createTextRange();
            preCaretTextRange.moveToElementText(element);
            preCaretTextRange.setEndPoint("EndToEnd", textRange);
            caretOffset = preCaretTextRange.text.length;
        }
        return caretOffset;
    }


</script>
</head>
<body onselectstart="return true;" ondragstart="return false;" class="discuss_comment">
	<div id="container" class="container">
	    <header></header>
	    <div class="body">
	        <form id="form_1" action="{$site_info.route_base}/index/addcomment?app_id={$site_info.app_id}&tid={$data.tid}&cid={$data.cid}&uid={$data.uid}&exa_praise=0&ruid={$data.uid}" method="post">
	            <section class="form_comment">
	                <header>
	                    <ul class="tbox">
	                        <li>
	                           <label class="title">回复 {$user_info.nick}</label>
	                        </li>
	                        <li class="align_right">
	                            <a href="javascript:history.go(-1);" class="cancel">取消</a>
	                        </li>
	                    </ul>
	                </header>
	                <article id="form_article" onpaste="myInput.listen(this, event);" onkeydown="myInput.listen(this, event);" oninput="myInput.listen(this, event);" placeholder="写评论..." maxlength="10" contenteditable="true"></article>
	                <input id="form_article_hidden" name="form_article" value="" type="hidden">
	                <footer>
	                    <div class="align_right">
	                        <label id="form_count">140 字</label>
	                    </div>
	                </footer>
	            </section>
	            <section class="form_pic_emotion">
	                <div>
	                    <nav>
	                        <ul id="nav_nav">
	                            <li>
	                                <a href="javascript:;" class="on" onclick="$('#page_emotion').toggleClass('on');">
	                                   <span class="icons icons_emotion">&nbsp;</span>
	                                </a>
	                            </li>
	                        </ul>
	                    </nav>
	                </div>
	                <div>
	                    <ul class="page_pic_emotion clear" id="nav_page">
	                        <li class="page_emotion box_swipe" id="page_emotion">
	                            <dl id="list_emotion" class="list_emotion pt_10">
	                                <div>
	                                    <!-- <dd><span data-key="0-0-/::)" style="background-position:0px 0;"></span></dd> -->
	                                </div>
	                            </dl>
	                            <dt>
	                                <ol id="nav_emotion" class="nav_emotion">
	                                    <span class="on"></span>
	                                    <span></span>
	                                </ol>
	                            </dt>
	                        </li>
	                    </ul>
	                </div>
	            </section>
	
	        </form>
	    </div>
	    <footer>
	        <section class="nav_footer">
	            <ul class="box">
	                <li>
	                    <a href="javascript:submit();" class="on" style="width:120px;">
	                        <span class="icons_publish">&nbsp;</span>
	                        <label class="pre">确认提交</label>
	                    </a>
	                </li>
	            </ul>
	        </section>
	    </footer>
	</div>
    
<script>
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
    WeixinJSBridge.call('hideOptionMenu');
});
</script>

<script type="text/javascript">
(function() {
    var wtj = document.createElement('script'); wtj.type = 'text/javascript'; wtj.async = true;
    wtj.src = 'http://tj.weimob.com/wtj.js?url=' + encodeURIComponent(location.href);
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wtj, s);
})();
function weimobAfterShare(shareFromWechatId,sendFriendLink,shareToPlatform){
    var wmShare = document.createElement('script'); wmShare.type = 'text/javascript'; wmShare.async = true;
    wmShare.src = 'http://tj.weimob.com/api-share.js?fromWechatId=' + shareFromWechatId + '&shareToPlatform=';
    wmShare.src += shareToPlatform + '&pid=0&sendFriendLink=' + encodeURIComponent(sendFriendLink);
    var stj = document.getElementsByTagName('script')[0]; stj.parentNode.insertBefore(wmShare, stj);
}

/**
 * 默认分享出去的数据
 *
 */
function getShareImageUrl(){

    var share_imgurl = "";
    if("" == share_imgurl){
        var shareImgObj = document.getElementsByClassName("shareImgUrl")[0];
        if('undefined' != typeof(shareImgObj)){
            share_imgurl = shareImgObj.src;
        }
    }
    return window.shareData.imgUrl || share_imgurl;
}

window.shareData = window.shareData || {
    "timeLineLink": "http://349257.m.weimob.com/snsmobile/commentview?sid=349257&tid=3533&cid=4570&uid=387016&exa_praise=0&ruid=387016&t=1",
    "sendFriendLink": "http://349257.m.weimob.com/snsmobile/commentview?sid=349257&tid=3533&cid=4570&uid=387016&exa_praise=0&ruid=387016&t=1",
    "weiboLink": "http://349257.m.weimob.com/snsmobile/commentview?sid=349257&tid=3533&cid=4570&uid=387016&exa_praise=0&ruid=387016&t=1",
    "tTitle": document.title,
    "tContent": document.title,
    "fTitle": document.title,
    "fContent": document.title,
    "wContent": document.title
}


//loadChangeUrlChannel("timeLineLink","fc");
//loadChangeUrlChannel("sendFriendLink","f");

document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
    //loadChangeUrlChannel();
    // 发送给好友
    WeixinJSBridge.on('menu:share:appmessage', function (argv) {
        WeixinJSBridge.invoke('sendAppMessage', { 
            "img_url": getShareImageUrl(),
            "img_width": "640",
            "img_height": "640",
            "link": window.shareData.sendFriendLink,
            "desc": window.shareData.fContent,
            "title": window.shareData.fTitle
        }, function (res) {
            if('send_app_msg:cancel' != res.err_msg){
                weimobAfterShare("",window.shareData.sendFriendLink,'appmessage');
            }
            _report('send_msg', res.err_msg);
        })
    });

    // 分享到朋友圈
    WeixinJSBridge.on('menu:share:timeline', function (argv) {
        
        WeixinJSBridge.invoke('shareTimeline', {
            "img_url": getShareImageUrl(),
            "img_width": "640",
            "img_height": "640",
            "link": window.shareData.timeLineLink,
            "desc": window.shareData.tContent,
            "title": window.shareData.tTitle
        }, function (res) {
            if('share_timeline:cancel' != res.err_msg){
                //如果用户没有取消
                weimobAfterShare("",window.shareData.timeLineLink,'timeline');
            }
            _report('timeline', res.err_msg);
        });
    });

    // 分享到微博
    WeixinJSBridge.on('menu:share:weibo', function (argv) {
        WeixinJSBridge.invoke('shareWeibo', {
            "content": window.shareData.wContent,
            "url": window.shareData.weiboLink
        }, function (res) {
            if('share_weibo:cancel' != res.err_msg){
                weimobAfterShare("",window.shareData.weiboLink,'weibo');
            }
            _report('weibo', res.err_msg);
        });
    });
}, false);

</script>

<script type="text/javascript" src="/sources/js/share_channel.js"></script>
<script type="text/javascript" src="/sources/js/base64.js"></script>
<script type="text/javascript" src="/sources/js/st.js"></script>
</body>
</html>